Globals in Macros.carp

*=

macro

Macro

                        (*= var val)
                    

Sets the value of a variable to its current value multiplied by val.

++

macro

Macro

                        (++ var)
                    

Sets the value of a variable to its current value incremented by one.

+=

macro

Macro

                        (+= var val)
                    

Sets the value of a variable to its current value plus val.

--

macro

Macro

                        (-- var)
                    

Sets the value of a variable to its current value decremented by one.

-=

macro

Macro

                        (-= var val)
                    

Sets the value of a variable to its current value minus val.

and

macro

Macro

                        (and :rest xs)
                    

evaluates the forms xs one at a time, from left to right. If a form evaluates to false, and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last form in xs. (and) returns true.

annotate

macro

Macro

                        (annotate name annotation)
                    

Add an annotation to this binding.

c-name

macro

Macro

                        (c-name sym cname)
                    

Override the identifiers Carp generates for a given symbol in C output.

(defn foo-bar [] 1)
(c-name foo-bar "foo_bar")

comment

macro

Macro

                        (comment :rest forms)
                    

ignores forms.

cond

macro

Macro

                        (cond :rest xs)
                    

Executes a block of code if a specified condition is true. Multiple such blocks can be chained.

(cond
  (< 10 1) (println "Condition 1 is true")
  (> 10 1) (println "Condition 2 is true")
  (println "Else branch"))

const-assert

dynamic

Dynamic

                        (const-assert expr msg)
                    

Asserts that the expression expr is true at compile time. Otherwise it will fail with the message msg.

The expression must be evaluable at compile time.

def-

macro

Macro

                        (def- name value)
                    

Declares a variable while marking it as private and hidden.

defdynamic-once

macro

Macro

                        (defdynamic-once var expr)
                    

Creates a dynamic variable and sets its value if it's not already defined.

defn-

macro

Macro

                        (defn- name args form)
                    

Declares a function while marking it as private and hidden.

deprecated

macro

Macro

                        (deprecated name :rest explanation)
                    

Declares that a binding is deprecated, using an optional explanation.

doc

macro

Macro

                        (doc name :rest strings)
                    

Set documentation for a binding.

hidden

macro

Macro

                        (hidden name)
                    

Mark a binding as hidden, this will make it not print with the 'info' command.

hidden?

macro

Macro

                        (hidden? name)
                    

Is this binding hidden?

ignore

macro

Macro

                        (ignore form)
                    

ignores the return value of the expression form.

ignore*

macro

Macro

                        (ignore* :rest forms)
                    

Wraps all forms passed as an argument in a call to ignore.

implements-all

macro

Macro

                        (implements-all mod :rest interfaces)
                    

Declares functions in mod with names matching interfaces as implementations of those interfaces.

inline-c

macro

Macro

                        (inline-c name defcode :rest declcode)
                    

Inlines some custom C code.

load-and-use

macro

Macro

                        (load-and-use name)
                    

loads a file and uses the module with in it. Assumes that the filename and module name are the same.

or

macro

Macro

                        (or :rest xs)
                    

evaluates the forms xs one at a time, from left to right. If a form evaluates to true, or returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last form in xs. (or) returns false.

macro

Macro

                        (print-doc name)
                    

Print the documentation for a binding.

macro

Macro

                        (print-sig name)
                    

Print the annotated signature for a binding.

private

macro

Macro

                        (private name)
                    

Mark a binding as private, this will make it inaccessible from other modules.

private?

macro

Macro

                        (private? name)
                    

Is this binding private?

refstr

macro

Macro

                        (refstr x)
                    

stringifies x and takes the reference of that string.

sig

macro

Macro

                        (sig name signature)
                    

Annotate a binding with the desired signature.

swap!

macro

Macro

                        (swap! x y)
                    

swaps its arguments x and y in place.

Note: Unhygienic!

todo

macro

Macro

                        (todo name value)
                    

sets the todo property for a binding.

unreachable

macro

Macro

                        (unreachable msg)
                    

Asserts that a block of code will never be reached. If it is the program will be aborted with an error message.

update!

macro

Macro

                        (update! x f)
                    

updates x in place using the function f.

use-all

macro

Macro

                        (use-all :rest names)
                    

is a variadic version of use.